package algorithm.poj;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;


/**
 * id: 1002 
 * NOTE: using HashTable
 * @author wong.tong@gmail.com
 *
 */
public class PhoneNumber {

	public static void main(String[] args) throws Exception {
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));

        String line;

        line = stdin.readLine();
        int cnt = Integer.valueOf(line.trim());
        Map<String, Integer> hash = new HashMap<String, Integer>();
        String key = null;
        Integer val = null;
        while (cnt > 0) {
        	line = stdin.readLine();
        	key = pn2str(convert(line));
        	val = hash.get(key);
        	if (val == null) {
        		hash.put(key, 1);
        	} else {
        		val = val.intValue() + 1;
        		hash.put(key, val);
        	}
            cnt --;
        }

        Set<String> keySet = hash.keySet();
        String[] keys = keySet.toArray(new String[keySet.size()]);
        for (String k: keys) {
        	if (hash.get(k).intValue() == 1) {
        		hash.remove(k);
        	}
        }
        
        keySet = hash.keySet();
        if (keySet.size() == 0) {
        	System.out.println("No duplicates.");
        } else {
            keys = keySet.toArray(new String[keySet.size()]);
            Arrays.sort(keys);
            
            for (String k: keys) {
            	System.out.println(k + " " + hash.get(k));
            }
        }
	}
	
	private static int[] convert(String pn) {
		
		int[] m = new int[7];
		int cur = -1;
		char c ;
		for (int i = 0; i < pn.length(); i ++) {
			c = pn.charAt(i);
			if (map(c) == -1) {
				continue;
			} else {
				cur ++;
				if (cur < 7) {
					m[cur] = map(c); 
				}
			}
		}
		return m;
	}
	
	private static String pn2str(int[] m) {
		return ""+m[0]+m[1]+m[2]+"-"+m[3]+m[4]+m[5]+m[6];
	}
	
	private static int map(char c) {
		switch (c) {
		case 'A':
		case 'B':
		case 'C':
			return 2;
		case 'D':
		case 'E':
		case 'F':
			return 3;
		case 'G':
		case 'H':
		case 'I':
			return 4;
		case 'J':
		case 'K':
		case 'L':
			return 5;
		case 'M':
		case 'N':
		case 'O':
			return 6;
		case 'P':
		case 'R':
		case 'S':
			return 7;
		case 'T':
		case 'U':
		case 'V':
			return 8;
		case 'W':
		case 'X':
		case 'Y':
			return 9;
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			return c-'0';
		default:
			return -1;
		}
	}
}
